
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets" template="/template/main.xhtml">

	<ui:define name="body">
		<h:form prependId="false">

			<p:toolbar>
				<p:toolbarGroup align="left">
					<p:commandButton value="#{messages['button.save']}" action="#{tipoObraEditMB.insert}"
						rendered="#{!tipoObraEditMB.updateMode}" ajax="false" />
					<p:commandButton value="#{messages['button.save']}" action="#{tipoObraEditMB.update}"
						rendered="#{tipoObraEditMB.updateMode}" ajax="false" />
					<p:commandButton value="#{messages['button.delete']}" onclick="confirmation.show()"
						rendered="#{tipoObraEditMB.updateMode}" type="button" immediate="true" ajax="false" />
					<p:confirmDialog message="#{messages['label.confirm.delete']}" showEffect="bounce" hideEffect="explode"
						header="#{messages['label.dialog.delete']}" severity="alert" widgetVar="confirmation">
						<h:commandButton value="#{messages['button.dialog.yes']}" action="#{tipoObraEditMB.delete}" immediate="true"
							ajax="false" />
						<h:commandButton value="#{messages['button.dialog.no']}" onclick="confirmation.hide()" type="button" />
					</p:confirmDialog>
				</p:toolbarGroup>
			</p:toolbar>

			<br />

			<p:fieldset legend="#{messages['tipoObra.label']}" toggleable="true" toggleSpeed="500">
				<h:panelGrid id="fields" columns="3">
					
					<h:outputLabel value="#{messages['tipoObra.label.id']}: " for="id" styleClass="text-input" />
					<h:outputText id="id" value="#{tipoObraEditMB.bean.id}" />
					<p:message for="id" />
					
					<h:outputLabel value="#{messages['tipoObra.label.descricao']}: " for="descricao" styleClass="text-input" />
					<h:inputText id="descricao"  maxlength="100" size="80" required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" value="#{tipoObraEditMB.bean.descricao}"
						title="#{messages['tipoObra.alt.descricao']}" />
					<p:message for="descricao" />
					
				</h:panelGrid>
			</p:fieldset>
		</h:form>

		
		<p:spacer height="20" width="20"/>  

		<h:form prependId="false">
			<p:fieldset legend="#{messages['exigencia.list.table.title']}" toggleable="true" toggleSpeed="500">

				<h:panelGrid id="fields2" columns="3">

					<h:outputLabel value="#{messages['itemTabelaPreco.label.codigoExigencia']}: " for="codigoExigencia" styleClass="text-input" />
					<h:inputText id="codigoExigencia"  maxlength="100" required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" value="#{tipoObraEditMB.codigoExigencia}"
						title="#{messages['itemTabelaPreco.alt.codigoExigencia']}" />
					<p:message for="codigoExigencia" />

					<h:outputLabel value="#{messages['itemTabelaPreco.label.descricaoExigencia']}: " for="descricaoExigencia" styleClass="text-input" />
					<h:inputTextarea id="descricaoExigencia"  maxlength="1000" required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}" 
					style="width:420" value="#{tipoObraEditMB.descricaoExigencia}"
						title="#{messages['itemTabelaPreco.alt.descricaoExigencia']}" />
					<p:message for="descricaoExigencia" />

					<h:outputLabel value="#{messages['itemTabelaPreco.label.obrigatorio']}: " for="obrigatorio" styleClass="text-input" />
					<h:selectOneRadio styleClass="tableRadios" id="obrigatorio" value="#{tipoObraEditMB.obrigatorio}" 
				    	required="true" requiredMessage="#{messages['mensagem_geral.campoObrigatorio']}">  
			             <f:selectItem itemLabel="Sim" itemValue="S" />
			             <f:selectItem itemLabel="Não" itemValue="N" />
			         </h:selectOneRadio>
					<p:message for="obrigatorio" />

					<f:facet name="footer">
				    	<h:panelGroup>

							<h:commandButton value="#{messages['button.add']}"  action="#{tipoObraEditMB.adicionarExigencia()}" ajax="true" >
				    			<f:ajax execute="fields2" render="fields2" />
				    	   	</h:commandButton>
							<p:message for="list"/>

							<p:dataTable id="list" var="bean" value="#{tipoObraEditMB.bean.listaExigenciaTipoObra}" rowIndexVar="rowIndex" >
								<f:facet name="header">#{messages['itemTabelaPreco.list.table.title']}</f:facet>

								<p:column style="width:5%;" sortBy="#{rowIndex}">
									<f:facet name="header">#{messages['button.remove']}</f:facet>
									<h:commandButton value="#{messages['button.remove']}" action="#{tipoObraEditMB.removerExigencia()}" ajax="true" >
						    			<f:ajax execute="list" render="list" immediate="true"/>
										<f:setPropertyActionListener target="#{tipoObraEditMB.posicao}" value="#{rowIndex}" />
									</h:commandButton>
								</p:column>

								<p:column sortBy="#{bean.codigoExigencia}">
									<f:facet name="header">#{messages['itemTabelaPreco.label.codigoExigencia']}</f:facet>
										<h:outputText value="#{bean.codigoExigencia}" />
								</p:column>

								<p:column sortBy="#{bean.descricao}">
									<f:facet name="header">#{messages['itemTabelaPreco.label.descricaoExigencia']}</f:facet>
										<h:outputText value="#{bean.descricao}" />
								</p:column>

								<p:column sortBy="#{bean.obrigatorio}">
									<f:facet name="header">#{messages['itemTabelaPreco.label.obrigatorio']}</f:facet>
									<h:outputText value="Sim" rendered="#{bean.obrigatorio eq 'S'}"  />
									<h:outputText value="Não" rendered="#{bean.obrigatorio eq 'N'}"  />
								</p:column>

							</p:dataTable>
				  		</h:panelGroup>
				  	</f:facet>
				</h:panelGrid>
			</p:fieldset>
		</h:form>

	</ui:define>
</ui:composition>